<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>设置密码</title>
    <link rel="shortcut icon" href="/favicon1.ico" type="image/x-icon">
    <meta charset="utf-8">
    <base href="<%=request.getContextPath()%>/">
    <link href="static/plugin/bootstrapValidator/css/bootstrapValidator.css" rel="stylesheet">
    <link href="static/bootstrap/css/bootstrap.css" rel="stylesheet">
    <link href="static/plugin/sweetAlert/css/sweet-alert.css" rel="stylesheet">

    <style>
        .loginBody {
            background: url("<%=request.getContextPath()%>/static/layout/image/login_bg.jpg") no-repeat #E9F0F4;
        }
        .btn-blue {
            height: 40px;
            line-height: 40px;
            padding: 0;
            border: none;
            background-color: #66b7ff;
            color: #fff !important;
            border-radius: 2px;
        }

        .btn-blue:hover {
            background-color: #4DAAFF;
        }

        .aw-register-box input[type="text"], .aw-register-box input[type="password"] {
            width: 100%;
            height: 40px;
            line-height: 28px \0;
            padding-left: 15px !important;
            box-shadow: none;
            border-color: #e6e6e6;
        }

        .input-group-addon {
            padding: 6px 12px;
            font-size: 14px;
            font-weight: normal;
            line-height: 1;
            color: #3c763d;
            text-align: center;
            background-color: #ffffff;
            border: 1px solid #e6e6e6;
            border-radius: 4px;
        }

        .has-success .input-group-addon {
            /*color: #3c763d;*/
            background-color: #ffffff;
            border-color: #e6e6e6;
        }

        .has-success .form-control:focus {
            border-color: #e6e6e6;
            -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .0), 0 0 6px #e6e6e6;
        }

        h3 {
            margin: 45px 0 0;
            font-size: 20px;
            color: #666666;
        }

        h2 {
            font-family: '楷体';
            margin-bottom: 10px;
            font-size: 30px;
            line-height: 1.2;
            font-weight: bold;
            color: #333;
        }

        .waitImg {
            background-image: url("<%=request.getContextPath()%>/static/layout/image/wait.gif");
            height: 30px;
            width: 30px;
            background-repeat: no-repeat;
            background-size: 30px 30px;
            margin: 0 auto;
        }

        #main {
            position: absolute;
            width: 680px;
            height: 500px;
            left: 50%;
            top: 50%;
            margin-left: -340px;
            margin-top: -250px;
            background-color: #ffffff;
            border-radius: 4px
        }
    </style>


</head>

<body class="loginBody">

<div>
    <div id="main">
        <div style="height: 180px ;padding-top: 50px">
            <h2 align="center" class="">上海市质监局专家管理系统</h2>
        </div>

        <form id="form_data" class="form-horizontal row " >

            <div class="form-group col-sm-12 " style="margin-bottom: 20px">
                <div class="col-sm-6  col-sm-offset-3 aw-register-box">
                    <h3 style="display: block;margin: 0px auto;text-align: center">
                        设置密码
                    </h3>
                </div>
            </div>
            <div class="form-group col-sm-12 " style="margin-bottom: 20px">
                <div class="col-sm-6  col-sm-offset-3 aw-register-box">
                    <div class="input-group  ">
                                                <span class="input-group-addon"><span
                                                        class="glyphicon glyphicon-lock"></span></span>
                        <input type="password" class="form-control  " name="password" placeholder="密码">
                    </div>
                </div>
            </div>

            <div class="form-group col-sm-12 " style="margin-bottom: 20px">
                <div class="col-sm-6 col-sm-offset-3 aw-register-box">
                    <div class="input-group ">
                                                <span class="input-group-addon"><span
                                                        class="glyphicon glyphicon-lock"></span></span>
                        <input type="password" class="form-control " name="password1" placeholder="确认密码">
                    </div>

                </div>
            </div>


            <div class="form-group col-sm-12">
                <div class="col-sm-6  col-sm-offset-3">
                    <button id="btn_submit" style="width: 100%;text-align: center" type="submit"
                            class="btn btn-lg btn-blue btn-block">
                        &nbsp;确&nbsp;定&nbsp;</button>
                </div>
            </div>
            <div class="form-group col-sm-12">
                <div id="div_error" style="color: #a13314" class="col-sm-6  col-sm-offset-3 ">
                </div>
            </div>
        </form>
    </div>
</div>

<script src="static/jquery/jquery-1.9.1.min.js"></script>
<script src="static/bootstrap/js/bootstrap.js"></script>
<script src="static/plugin/bootstrapValidator/js/bootstrapValidator.min.js"></script>
<script src="static/plugin/sweetAlert/js/sweet-alert.js"></script>

<script>
    $(function () {
        <%--bootstrapValidator--%>
        $("#form_data").bootstrapValidator({
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                password: {
                    validators: {
                        regexp: {
                            regexp: /^([0-9a-zA-Z]|[.。,，?？<《>》$￥()\[\]\{\}\\\+@~!#%^&*_-])+$/,
                            message: '出现非法字符'
                        }, stringLength: {
                            max: 20,
                            min: 6,
                            message: '密码长度6到20位！'
                        },
                        notEmpty: {
                            message: '不能为空！'
                        }, identical: {
                            field: 'password1',
                            message: '密码不一致'
                        }
                    }
                }, password1: {
                    validators: {
                        regexp: {
                            regexp: /^([0-9a-zA-Z]|[.。,，?？<《>》$￥()\[\]\{\}\\\+@~!#%^&*_-])+$/,
                            message: '出现非法字符！'
                        }, stringLength: {
                            max: 20,
                            min: 6,
                            message: '密码长度6到20位！'
                        },
                        notEmpty: {
                            message: '不能为空！'
                        }, identical: {
                            field: 'password',
                            message: '密码不一致'
                        }

                    }
                }
            }

        }).on('success.form.bv', function (e) {
            e.preventDefault();
            $("#div_error").html("");
            $("#btn_submit").html('<div class="waitImg"></div>');
            $.ajax({
                type: "POST",
                url: 'welcome/signUp/setPassword',
                data: $(e.target).serialize(),
                error: function () {
                    $("#div_error").html('系统异常');
                    $("#btn_submit").html('');
                },
                success: function (data) {
                    if (data.status == '1') {
                        swal({
                                    title: "设置成功",
                                    type: "success",
                                    showConfirmButton: true
                                }, function () {
                                    window.location.href = 'index.jsp';
                                }
                        );
                    } else {
                        $("#form_data").data('bootstrapValidator').resetForm();
                        $("#div_error").html(data.message);
                        $("#btn_submit").html('&nbsp;确&nbsp;定&nbsp;');
                    }
                }
            });


        });
    });
</script>
</body>

</html>